<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:include page="global.jsp"></jsp:include>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客户信息查询</title>
<style type="text/css">
.ctl{
	text-decoration: none;
	color: blue;
	margin: auto 7px;
}
.ctl:HOVER{
	text-decoration: underline;
}
.center{
	text-align: center;
}
</style>
</head>
<body>
	<table id="dg" class="easyui-datagrid" title="客户信息管理"
			data-options="
				rownumbers:true,
				iconCls: 'icon-edit',
				singleSelect: true,
				toolbar: '#tb',
				singleSelect:true,
				pagination:true,
				fit:true,
				fitColumns:true,
				pageList:[20,25,30,35,40,45,50],
				pageSize:20
			">
		<thead>
			<tr>
				<th data-options="field:'name',width:200,align:'center'">客户名称</th>
				<th data-options="field:'code',width:200,align:'center',align:'center'">客户编码</th>
				<th data-options="field:'address',width:200,align:'center'">地址</th>
				<th data-options="field:'id',width:80,align:'center',formatter:formatControl">查看</th>
			</tr>
		</thead>
	</table>

	<div id="tb" style="height:auto">
		
		<div>
			客户名称: <input class="easyui-textbox" type="text" id="name" style="width:240px;height:25px;">
			<a href="javascript:search()" class="easyui-linkbutton" iconCls="icon-search">查 找</a>
		</div>
	</div>
	
	<div id="lookDetail" class="easyui-window" title="客户信息详情" data-options="modal:true,closed:true,iconCls:'icon-search'" style="width:600px; height:350px;padding:5px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'center'" style="padding:10px;">
				<table width="100%" height="100%">
					<tr>
						<td width="100px;" align="right">客户名称：</td>
						<td>
							<input class="easyui-textbox" id="lookName" readonly="readonly" style="width: 420px;" />
						</td>
					</tr>
					<tr>
						<td width="100px;" align="right">客户编码：</td>
						<td>
							<input class="easyui-textbox" id="lookCode" readonly="readonly" style="width: 420px;" />
						</td>
					</tr>
					<tr>
						<td align="right">客户地址：</td>
						<td>
							<input class="easyui-textbox" id="lookAddress" readonly="readonly" style="width: 420px; height: 60px;" data-options="multiline:true" />
						</td>
					</tr>
					<tr>
						<td align="right">备注：</td>
						<td>
							<input class="easyui-textbox" id="lookRemark" style="width: 420px; height: 60px;" data-options="multiline:true" readonly="readonly" />
						</td>
					</tr>
				</table>
			</div>
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:$('#lookDetail').window('close')" style="width:80px">关 闭</a>
			</div>
		</div>
	</div>
	
	<script type="text/javascript">
		function formatControl(val, row){
			return '<a class="ctl" href="javascript:void(0)" onclick="lookDetail(' + val + ')">基本信息</a>';
		}
		function search(){
			var dg = $("#dg");
			var name = $("#name").textbox("getValue").trim();
			var url = "queryCustomer?name=" + name;
			dg.datagrid('reload', url);
		}
		function lookDetail(id){
			var data = "id=" + id;
			$.ajax({
			  	type: "GET",
			  	url: "findCustomer",
			  	data: data,
			  	success:function(data){
					var val = $.parseJSON(data);
					if(val.success){
						var item = val.data;
						
						$("#lookName").textbox("setValue", item.name);
						$("#lookCode").textbox("setValue", item.code);
						$("#lookAddress").textbox("setValue", item.address);
						$("#lookRemark").textbox("setValue", item.remark);
						
						$('#lookDetail').window('open');
					}else{
						$.messager.alert("提示", val.msg, "error");
					}
			  	}
			});
		}
		$(function(){
			search();
		});
	</script>
</body>
</html>